<div ng-controller="goodsCtrl">
    <div class="bg-light lter b-b wrapper-md ng-scope">
        <h4 class="m-n font-thin">商品管理</h4>
    </div>
    <div class="wrapper-md">
        <div class="panel">
            <div class="row wrapper">
                <div class="col-sm-9">
                    <form class="form-inline ng-pristine ng-valid">
                        <div class="form-group">
                            <label class="control-label">商品名称</label>
                            <input type="text" class="input-sm form-control" ng-model="goodsListVO.name" placeholder="商品的名称">
                        </div>
                        <div class="form-group">
                            <label class="control-label">商品类型</label>
                            <select class="input-sm form-control" ng-model="goodsListVO.typeId" ng-options="item.id as item.fullName for item in types">
                                <option value="">全部</option>
                            </select>
                        </div>
                        <div class="form-group">
                            <label class="control-label">品牌名称</label>
                            <select class="input-sm form-control" ng-model="goodsListVO.brandId" ng-options="item.id as item.name for item in brands">
                                <option value="">全部</option>
                            </select>
                        </div>
                        <div class="form-group">
                            <label class="control-label">经营类型</label>
                            <select class="input-sm form-control" ng-model="goodsListVO.type">
                                <option value="">－－请选择－－</option>
                                <option value="0">到店</option>
                                <option value="1">配送</option>
                                <option value="2">直邮</option>
                                <option value="3">堂食</option>
                                <option value="4">预定</option>
                            </select>
                        </div>
                        <div class="form-group">
                            <label class="control-label">状态</label>
                            <select class="input-sm form-control" ng-model="goodsListVO.status">
                                <option value="">全部</option>
                                <option value="0">下架</option>
                                <option value="1">上架</option>
                                <option value="2">待审核</option>
                                <option value="3">审核不通过</option>
                                <option value="4">审核通过</option>
                            </select>
                        </div>
                        <button class="btn btn-sm btn-default" ng-click="findPageAll()">查询</button>
                    </form>
                </div>
                <div class="col-sm-3">
                    <div class=" pull-right" ng-if="app.shop.isCustomGoods==1">
                        <a class="btn btn-sm btn-info" ui-sref="app.goodsAdd">添加商品</a>
                    </div>
                    <div class=" pull-right">
                        <a class="btn btn-sm btn-info" ui-sref="app.chainGoodsAdd" target="_blank" ng-if="app.shop.isChain==1">导入商品</a>
                    </div>
                </div>
                <div class="clearfix"></div>
            </div>
            <div class="table-responsive pos-rlt">
                <table class="table table-striped b-t b-light pos-rlt">
                    <thead>
                        <tr>
                            <th width="20">
                                <label class="i-checks i-checks-sm m-b-none">
                                    <input type="checkbox" ng-checked="isCheckedAll()" ng-click="checkAll($event)"><i></i>
                                </label>
                            </th>
                            <th>编号</th>
                            <th>图片/商品详情</th>
                            <th>库存/运费</th>
                            <th>品牌</th>
                            <th>让利值(%)</th>
                            <th>系统类型</th>
                            <th>经营类型</th>
                            <th>销售类型</th>
                            <th>是否推荐</th>
                            <th>是否扶农</th>
                            <th>状态</th>
                            <!--<th>更新时间</th>-->
                            <th width="200">操作</th>
                        </tr>
                    </thead>
                    <tbody>
                         <tr ng-if="list.length>0" ng-repeat="item in list" ng-init="initSelect()">
                            <td><label class="i-checks i-checks-sm m-b-none"><input type="checkbox" name="post[]" ng-checked="isChecked(item)" ng-click="updateSelection($event,item)"><i></i></label></td>
                            <td>{{item.code}}</td>
                            <td width="20%">
                                <div class="inline">
                                    <img src="img/default.png" ng-src="{{app.image.goods}}{{item.fileName}}" err-src="img/error.png" style="height: 60px;width: 60px;" class="pull-left m-r-sm">
                                    <div class="pull-left">
                                        <p class="block h5 font-bold m-b-xs w-sm text-ellipsis">{{item.name}}</p>
                                        <p class="block h6 m-b-xs">类型:{{item.typeName}}</p>
                                        <p class="h6 m-b-xs" ng-if="item.type == 5">积分:{{item.integral}}</p>
                                        <p class="h6 m-b-xs" ng-if="item.isOpenSku==0">单价:{{item.price | number:2}}元</p>
                                        <p class="h6 m-b-xs" ng-if="item.isOpenSku==1">单价范围:{{item.skuRangePrice}}元</p>
                                        <p class="h6 m-b-xs">参考价:<del>{{item.referencePrice | number:2}}元</del></p>
                                    </div>
                                </div>
                            </td>
                            <td ng-if="item.type != 4">
                                <span class="h6 block font-bold m-b-xs">库存:{{item.stock | number}}件</span>
                                <p class="h6 block m-b-xs" ng-if="item.postageType==0">运费: 包邮</p>
                                <p class="h6 block m-b-xs" ng-if="item.postageType==1">统一运费: {{item.postagePrice | number:2}}元</p>
                                <p class="h6 block m-b-xs" ng-if="item.postageType==2">
                                    运费模板:{{item.postageTemplateName}}
                                    <a class="text-info inline h6" ui-sref="app.postage">查看</a>
                                </p>
                                <p class="h6 m-b-xs" ng-if="item.type==1">餐盒费: {{item.foodBoxCharge | number:2}}元</p>
                             </td>
                             <td ng-if="item.type == 4">
                                 暂无
                             </td>
                            <td>
                                <p>{{item.brandName}}</p>
                            </td>
                             <td>
                                 {{item.profit}}
                             </td>
                             <td>
                                 <span class="w-xs text-ellipsis" alt="{{item.systemType}}">{{item.systemType}}</span>
                             </td>
                             <td>
                                 <p ng-if="item.type==0" class="label bg-success h6">到店</p>
                                 <p ng-if="item.type==1" class="label bg-warning h6">配送</p>
                                 <p ng-if="item.type==2" class="label bg-info h6">直邮</p>
                                 <p ng-if="item.type==3" class="label bg-primary h6">堂食</p>
                                 <p ng-if="item.type==4" class="label bg-danger h6">预定</p>
                                 <p ng-if="item.type==5" class="label bg-danger h6">积分</p>
                             </td>
                             <td>
                                 SKU：<span ng-bind="{0:'未开启',1:'开启'}[item.isOpenSku]"></span><br>
                                 分销：<span ng-bind="{0:'未开启',1:'开启'}[item.isOpenSell]"></span><br>
                                 返利：<span ng-bind="{0:'未开启',1:'开启'}[item.isOpenRebate]"></span>
                             </td>
                             <td>
                                 <span class="label bg-light" ng-class="{0:'bg-light',1:'bg-success'}[item.isRecommend]" ng-bind="{0:'否',1:'是'}[item.isRecommend]"></span>
                             </td>
                             <td>
                                 <span class="label bg-light" ng-class="{0:'bg-light',1:'bg-success'}[item.isHelpPeasant]" ng-bind="{0:'否',1:'是'}[item.isHelpPeasant]"></span>
                             </td>
                            <td>
                                <span class="label bg-light dk" ng-class="{0:'bg-light',1:'bg-success'}[item.status]" ng-bind="{0:'下架',1:'上架',2:'待审核',3:'审核不通过',4:'审核通过'}[item.status]"></span>
                                <i class="m-l-xs fa fa-question-circle text-muted pos-rlt h6" popover-placement="top" popover="原因:{{item.auditFailDescription}}" popover-trigger="mouseenter" ng-if="item.status==3"></i>
                            </td>
                             <!--<td>-->
                                 <!--<span class="h6">{{item.updatedTime}}</span>-->
                             <!--</td>-->
                            <td class="t-btns">
                                <a class="btn btn-sm btn-success" ui-sref="app.goodsDetail({id:item.id})" target="_blank" ng-if="item.type!=4">查看</a>
                                <a class="btn btn-sm btn-success" ng-click="checkReserve(item.id)" target="_blank" ng-if="item.type==4">查看</a>
                                <a class="btn btn-sm btn-info" ui-sref="app.goodsEdit({id:item.id})" ng-click="allowEditGoods(item.id,item.status)" target="_blank">修改</a>
                                <div class="btn-group dropdown" dropdown="">
                                    <button class="btn btn-sm btn-default" dropdown-toggle="" aria-haspopup="true" aria-expanded="false">更多 <span class="caret"></span>
                                    </button>
                                    <ul class="dropdown-menu">
                                        <li><a ui-sref="app.goodsDetailevaluate({id:item.id})" target="_blank">商品用户评价</a></li>
                                        <li><a ng-click="deleteGoods(item.id,item.name)">删除</a></li>
                                        <li ng-if="item.status==0 || item.status==1"><a href="" ng-click="updateStatus(item.id,item.status)" ng-bind="{1:'下架',0:'上架'}[item.status]">下架</a></li>
                                        <li ng-if="item.status==4"><a href="" ng-click="updateStatus(item.id,item.status)">上架</a></li>
                                        <li ng-if="item.status==3"><a href="" ng-click="updateStatus(item.id,item.status)">申请再审核</a></li>
                                    </ul>
                                </div>
                            </td>
                        </tr>
                    </tbody>
                </table>
                <div ng-if="list.length<=0 && !app.loading" class="padder-v text-center">
                    <span class="h6">~未搜索到任何数据~</span>
                </div>
                <div>
                    <circle-loading ng-if="app.loading"></circle-loading>
                </div>
            </div>
            <footer class="panel-footer">
                <div class="row">
                    <div class="col-sm-4 hidden-xs">
                        <button class="btn btn-sm btn-default" ng-click="batchUpdateDownStatus()">批量下架</button>
                        <button class="btn btn-sm btn-default" ng-click="batchUpdateUpStatus()">批量上架</button>
                        <button class="btn btn-sm btn-default" ng-click="batchDeleteGoods()">批量删除</button>
                        <i class="m-l-xs fa fa-question-circle text-muted pos-rlt h6" popover-placement="right" popover="待审核,审核不通过状态的商品不可执行批量上/下架操作" popover-trigger="mouseenter"></i>
                    </div>
                    <div class="col-sm-4 text-center">
                        <small class="text-muted inline m-t-sm m-b-sm">显示第 {{startRow}} 至 {{endRow}} 项结果，共 {{totalItems}} 项</small>
                    </div>
                    <div class="col-sm-4 text-right text-center-xs">
                        <pagination boundary-links="true" total-items="totalItems" ng-model="currentPage"
                                    ng-change="pageChanged()" max-size="{{maxPageRow}}" class="pagination-sm m-t-none m-b"
                                    previous-text="上一页" next-text="下一页"
                                    first-text="首页" last-text="尾页"></pagination>
                    </div>
                </div>
            </footer>
        </div>
    </div>

</div>